#!/bin/sh

pushd $(dirname $0) >/dev/null

# Command file for Sphinx documentation

sphinx_build_cmd=sphinx-build
source_dir=source
build_dir=_build

function help() {
	$sphinx_build_cmd -M help $source_dir$ $build_dir$ $sphinx_opts $0
	end $1
}

function end() {
	popd >/dev/null
	if [ "$1" != "" ]; then
		exit $1
	fi
	exit 0
}

source ./.venv/Scripts/activate
# test if sphinx is installed
$sphinx_build_cmd
if [ $? == 127 ]; then
	echo
	echo The 'sphinx-build' command was not found. Make sure you have Sphinx
	echo installed, then set the sphinx_build_cmd environment variable to point
	echo to the full path of the $(sphinx-build) executable. Alternatively you
	echo may add the Sphinx directory to PATH.
	echo
	echo If you don\'t have Sphinx installed, grab it from
	echo https://www.sphinx-doc.org/
	end 1
fi

if [ "$1" == "" ]; then
	help 2
fi

rm -rf $build_dir
$sphinx_build_cmd -M $1 $source_dir $build_dir
end
